home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / flashpc.exe / VIODEMO.C < prev    next >
Text File  |  1993-03-25  |  35KB  |  1,396 lines

  1. #include <fpclib.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <conio.h>
  6. #include <math.h>
  7.  
  8. typedef struct TCell {
  9.                      char Ch,Attr;
  10.                      } TCell;
  11.  
  12. void ClearTime( void );
  13. void Delay( int num );
  14. void str(int num, int digits, char *st );
  15. char UpCase( char ch );
  16. void DisplayTime( int NTimes );
  17. void TestBorderColor( void );
  18. void TestClrWin( void );
  19. void TestColorMsg( void );
  20. void TestEditSt( void );
  21. void TestFillColAttr( void );
  22. void TestFillColCell( void );
  23. void TestFillColChar( void );
  24. void TestFillFrameAttr( void );
  25. void TestFillFrameCell( void );
  26. void TestFillFrameChar( void );
  27. void TestFillRowAttr( void );
  28. void TestFillRowCell( void );
  29. void TestFillRowChar( void );
  30. void TestGetFrameAttr( void );
  31. void TestGetFrameCell( void );
  32. void TestGetFrameChar( void );
  33. void TestGetScrn( void );
  34. void TestPutScrn( void );
  35. void TestPutFrameAttr( void );
  36. void TestPutFrameCell( void );
  37. void TestPutFrameChar( void );
  38. void TestGetCursorSize( void );
  39. void TestFrameWin( void );
  40. void TestSetCursorSize( void );
  41. void TestRvsAttr( void );
  42. void TestGetVideoMode( void );
  43. void TestInitVideo( void );
  44. void TestGetVideoCols( void );
  45. void TestGetVideoPage( void );
  46. void TestGetVideoInfo( void );
  47. void TestSetVideoPage( void );
  48. void TestWhereXYAbs( void );
  49. void TestScrollLeft( void );
  50. void TestScrollRight( void );
  51. void TestScrollDown( void );
  52. void TestScrollUp( void );
  53. void TestWriteSt( void );
  54. void TestWriteStln( void );
  55. int  GetMenuSelection( void );
  56.  
  57.  
  58. char TCSet[32] = {  0,101,  0,0,0,0, 0,24,
  59.                    57,213,192,0,0,0,95, 0,
  60.                     8,  0,  0,0,0,0, 0, 0,
  61.                     0,  0,  0,0,0,0, 0, 0
  62.                  };
  63.  
  64. char VCSet[32] = {   0,  0,  0,  0,255,255,255,255,
  65.                    255,255,255,255,255,255,255,255,
  66.                    255,255,255,255,255,255,255,255,
  67.                    255,255,255,255,255,255,255,255
  68.                  };
  69.  
  70. int    i,j,i1,k,ChOfs,TE,
  71.        H1,M1,S1,Sec100_1,
  72.        H2,M2,S2,Sec100_2,
  73.        t1,t2,t3,Total;
  74.  
  75. char   St[256],Done;
  76.  
  77.  
  78. void ClearTime()
  79. {
  80.    H1 = M1 = S1 = Sec100_1 = 0;
  81.    H2 = M2 = S2 = Sec100_2 = 0;
  82.    Total = 0;
  83. }
  84.  
  85. void Delay(num)
  86. int num;
  87. {
  88.    int i;
  89.  
  90.    num *= 50;
  91.    for (i = 0; i <= num; i++)
  92.    ;
  93. }
  94.  
  95. void str(num,digits,st)
  96. char *st;
  97. int  num,digits;
  98. {
  99.    int i;
  100.  
  101.    *(st+digits) = '\0';
  102.    for (i = digits-1; i >= 0; i--) {
  103.       *(st+i) =  (char)( (num % 10) + 48 );
  104.       num /= 10;
  105.    }
  106. }
  107.  
  108. char UpCase(ch)
  109. char ch;
  110. {
  111.    if (ch >= 'a' && ch <= 'z')
  112.       ch -= 32;
  113.    return(ch);
  114. }
  115.  
  116. void DisplayTime(NTimes)
  117. int  NTimes;
  118. {
  119.    char   st[80];
  120.  
  121.  
  122.    WindowFP(15,10,65,14);
  123.    ClrWin( 15, 10, 65, 14, 48 );
  124.    FrameWin('╔','╗','╚','╝','═','║',48);
  125.  
  126.    strcpy( st, "Total Time = " );
  127.    itoa( Total, &st[13], 10 );
  128.    ColorMsg( 17, 11, 48, st );
  129.  
  130.    strcpy( st, "NTimes     = " );
  131.    itoa( NTimes, &st[13], 10 );
  132.    ColorMsg( 17, 12, 48, st );
  133.  
  134.  
  135.    strcpy( st, "Average time = " );
  136.    itoa( Total / NTimes , &st[15], 10 );
  137.    strcat( st, " hundredths of a second" );
  138.    ColorMsg( 17, 13, 48, st );
  139.  
  140.    for (i = 0; i < 3; i++)
  141.       FillRowAttr(16,i+11,50,48);
  142.    ColorMsg(18,14,144," Press any key to continue... ");
  143.    GetKey();
  144. }
  145.  
  146. void TestBorderColor()
  147. {
  148.    int  i;
  149.  
  150.    if ( VioMode == 7 ) {
  151.       ClrWin(1,1,80,25,7);
  152.       WindowFP(21,11,60,14);
  153.       ClrWin(21,11,60,14,48);
  154.       FrameWin('╔','╗','╚','╝','═','║',48);
  155.       ColorMsg(23,12,48,"Not Available on Monochrome monitors");
  156.       ColorMsg(23,13,48,"    Press any key to continue...");
  157.       WindowFP(1,1,80,25);
  158.    }
  159.    else {
  160.       GotoxyAbs(1,1);
  161.       for (i = 1; i <= 15; i++) {
  162.          BorderColor(i);
  163.          WriteStln("Press any key to continue...");
  164.          GetKey();
  165.       }
  166.    }
  167.    GetKey();
  168.    BorderColor(0);
  169. }
  170.  
  171. void TestClrWin()
  172. {
  173.    int    Color,TopRow,BottomRow,LeftCol,RightCol;
  174.  
  175.    ClrWin(1,1,80,25,7);
  176.    GotoxyAbs(1,1);
  177.    printf("\nEnter attribute value to clear screen with. 0-255 ==> ");
  178.    scanf("%d",&Color);
  179.    printf("\nEnter top row of area to clear. 1-25 ==> ");
  180.    scanf("%d",&TopRow);
  181.    printf("\nEnter left column of area to clear. 1-80 ==> ");
  182.    scanf("%d",&LeftCol);
  183.    printf("\nEnter bottom row of area to clear. %u-25 ==> ",TopRow);
  184.    scanf("%d",&BottomRow);
  185.    printf("\nEnter right column of area to clear. %u-80 ==> ",LeftCol);
  186.    scanf("%d",&RightCol);
  187.  
  188.    FillRowCell(1,1,2000,(65 << 8) + 7);
  189.    ColorMsg(1,1,48,"Press any key to clear area");
  190.    GetKey();
  191.    ClrWin(LeftCol,TopRow,RightCol,BottomRow,Color);
  192.    ColorMsg(1,1,48,"Press any key to return to menu");
  193.    GetKey();
  194. }
  195.  
  196. void TestColorMsg()
  197. {
  198.    char Msg[256];
  199.    int  i,Color,Char_Ofs = 1,TE = 0;
  200.  
  201.    TextAttr = 7;
  202.    do {
  203.       ClrWin(1,1,80,25,7);
  204.       GotoxyAbs(1,1);
  205.       WindowFP(10,1,69,3);
  206.       FrameWin('╔','╗','╚','╝','═','║',TextAttr);
  207.       ColorMsg(12,2,TextAttr,
  208.                "Enter 'QUIT' for message when you want to quit this test");
  209.       WindowFP(1,4,60,7);
  210.       FrameWin('╔','╗','╚','╝','═','║',TextAttr);
  211.       ColorMsg(3,4,TextAttr," ColorMsg data ");
  212.       ColorMsg(3,5,TextAttr,"Enter message to display ==> ");
  213.       for (i = 0; i < 255; Msg[i++] = '\0')
  214.       ;
  215.       EditSt(5,32,59,28,0,32,0,7000,2000,VCSet,TCSet,&Char_Ofs,&TE,Msg);
  216.       ColorMsg(3,6,TextAttr,"Enter the color to display message in ==> ");
  217.       GotoxyAbs(44,6);
  218.       scanf("%d",&Color);
  219.  
  220.       WindowFP(1,10,50,14);
  221.       FrameWin('╔','╗','╚','╝','═','║',TextAttr);
  222.  
  223.       ColorMsg(3,11,Color,Msg);
  224.       RvsAttr(TextAttr);
  225.       ColorMsg(2,13,TextAttr,
  226.                "          Press any key to continue...          ");
  227.       RvsAttr(TextAttr);
  228.       GetKey();
  229.       for (Color = 0; Color < 4; Color++)
  230.          if (Msg[Color] >= 'a' && Msg[Color] <= 'z')
  231.             Msg[Color] -= 32;
  232.  
  233.    } while (strcmp(Msg,"QUIT"));
  234. }
  235.  
  236. void TestEditSt()
  237. {
  238.    char  St[256];
  239.    int   i,Char_Ofs,TE;
  240.  
  241.    ClrWin(1,1,80,25,7);
  242.    ColorMsg(1,10,7,"Enter your name:");
  243.    for (i = 0; i <= 255; St[i++] = '\0')
  244.    ;
  245.    Char_Ofs = 1;
  246.    TE       = 0;
  247.    EditSt(10,18,28,30,1,7,0,7000,2000,VCSet,TCSet,&Char_Ofs,&TE,St);
  248.    RvsAttr(TextAttr);
  249.    GotoxyAbs(1,15);
  250.    WriteSt(St);
  251.    RvsAttr(TextAttr);
  252.    GetKey();
  253. }
  254.  
  255. void TestFillColAttr()
  256. {
  257.    int   i,NTimes = 80;
  258.  
  259.    ClrWin(1,1,80,25,7);
  260.    ClearTime();
  261.    for (i = 1; i <= NTimes; i++) {
  262.  
  263.       GetTime(&H1,&M1,&S1,&Sec100_1);
  264.       FillColAttr(i,1,25,i*16);
  265.       GetTime(&H2,&M2,&S2,&Sec100_2);
  266.  
  267.       if ((Sec100_2 > Sec100_1) || ((S1 == S2) && (Sec100_1 == Sec100_2)))
  268.          Total = Total + (Sec100_2 - Sec100_1);
  269.       else {
  270.          t1 = 100 - Sec100_1 + Sec100_2;
  271.          Total = Total + t1;
  272.       };
  273.    };
  274.    DisplayTime(NTimes);
  275. }
  276.  
  277. void TestFillColCell()
  278. {
  279.    int i,
  280.        NTimes = 80;
  281.  
  282.    ClrWin(1,1,80,25,7);
  283.    ClearTime();
  284.    for (i = 1; i <= NTimes; i++) {
  285.  
  286.       GetTime(&H1,&M1,&S1,&Sec100_1);
  287.       FillColCell(i,1,25,((i+64) << 8) + i);
  288.       GetTime(&H2,&M2,&S2,&Sec100_2);
  289.  
  290.       if ((Sec100_2 > Sec100_1) || ((S1 == S2) && (Sec100_1 == Sec100_2)))
  291.          Total = Total + (Sec100_2 - Sec100_1);
  292.       else {
  293.          t1 = 100 - Sec100_1 + Sec100_2;
  294.          Total = Total + t1;
  295.       };
  296.    };
  297.    DisplayTime(NTimes);
  298. }
  299.  
  300. void TestFillColChar()
  301. {
  302.    int i,
  303.        NTimes = 80;
  304.  
  305.    ClrWin(1,1,80,25,7);
  306.    ClearTime();
  307.    for (i = 1; i <= NTimes; i++) {
  308.  
  309.       GetTime(&H1,&M1,&S1,&Sec100_1);
  310.       FillColChar(i,1,25,(char)(i+64) );
  311.       GetTime(&H2,&M2,&S2,&Sec100_2);
  312.  
  313.       if ((Sec100_2 > Sec100_1) || ((S1 == S2) && (Sec100_1 == Sec100_2)))
  314.          Total = Total + (Sec100_2 - Sec100_1);
  315.       else {
  316.          t1 = 100 - Sec100_1 + Sec100_2;
  317.          Total = Total + t1;
  318.       };
  319.    };
  320.    DisplayTime(NTimes);
  321. }
  322.  
  323. void TestFillFrameAttr()
  324. {
  325.    int i,
  326.        NTimes = 15;
  327.  
  328.    ClrWin(1,1,80,25,7);
  329.    ClearTime();
  330.    for (i = 1; i <= NTimes; i++) {
  331.  
  332.       GetTime(&H1,&M1,&S1,&Sec100_1);
  333.       FillFrameAttr(1,1,80,25,i << 4);
  334.       GetTime(&H2,&M2,&S2,&Sec100_2);
  335.  
  336.       if ((Sec10